package com.example.hehecat.yuejian1.mvp.presenter;

import android.util.Log;

import com.example.hehecat.yuejian1.mvp.contract.ActivityListContract;
import com.example.hehecat.yuejian1.mvp.model.ActivityListModel;
import com.example.hehecat.yuejian1.mvp.model.bean.ActivityBean;

import java.util.List;

import rx.Subscriber;

import static android.support.constraint.Constraints.TAG;

public class ActivityListPresenter implements ActivityListContract.Presenter {
    private ActivityListContract.View view;
    private ActivityListContract.Model model;

    public ActivityListPresenter(ActivityListContract.View view) {
        this.view = view;
        model = new ActivityListModel();
    }

    @Override
    public void updateAdapterData() {
        model.getAllActivityData(new Subscriber<List<ActivityBean>>() {
            @Override
            public void onCompleted() {
                Log.d(TAG, "onNext: "+"onCompleted");
            }

            @Override
            public void onError(Throwable e) {
                Log.d(TAG, "onNext: "+e.toString());
            }

            @Override
            public void onNext(List<ActivityBean> activityBeans) {
                view.updateAdapterData(activityBeans);
//                Log.d(TAG, "onNext: "+activityBeans.get(0).getActivityname());
            }
        });
    }
}
